import { defineStore } from "pinia";

export const useCountStore = defineStore("count", {
  //真正存储数据的地方
  state() {
    return {
      sum: 0,
      school: "滚木",
      address: "121e41r",
    };
  },

  //里面放的都是一个一个动作函数/方法，用于相应组件中的动作
  //复用
  actions: {
    increment(value: number) {
      console.log("increment被调用了", value);
      //这是vue2吗？
      if (this.sum < 10) {
        this.sum += value;
      }
      this.school = "空白";
    },
  },
  getters: {
    bigSum: (state) => state.sum * 10,
    upperSchool: (state) => "棍母",
  },
});
